-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove duplicated code regarding user (room member and user profile) screens #3700
Conversation
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
private val factory: UserProfilePresenter.Factory, | ||
) : UserProfilePresenterFactory { | ||
override fun create(userId: UserId): Presenter<UserProfileState> = factory.create(userId) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This double factory level is a bit weird, there is maybe a better way to handle this. Any ideas @ganfra @jmartinesp ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see any, sorry... I was going to suggest trying to reuse UserProfilePresenter.Factory
but that's not possible since the AssistedFactory
needs to return a concrete type.
The best I could get was making UserProfilePresenter.Factory
implement UserProfilePresenterFactory
, then use it in DefaultUserProfilePresenterFactory
like this:
@ContributesBinding(SessionScope::class)
class DefaultUserProfilePresenterFactory @Inject constructor(
private val factory: UserProfilePresenter.Factory,
) : UserProfilePresenterFactory by factory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into it. Let's keep it like this then!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3700 +/- ##
===========================================
- Coverage 82.79% 82.77% -0.02%
===========================================
Files 1752 1751 -1
Lines 41967 41926 -41
Branches 5125 5120 -5
===========================================
- Hits 34746 34705 -41
- Misses 5398 5401 +3
+ Partials 1823 1820 -3 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, it's a shame we can't simplify it anymore.
@@ -55,6 +55,7 @@ class UserProfilePresenter @AssistedInject constructor( | |||
@Composable | |||
override fun present(): UserProfileState { | |||
val coroutineScope = rememberCoroutineScope() | |||
val isCurrentUser = remember { client.isMe(userId) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
client = client, | ||
) | ||
@Composable | ||
fun getDmRoomId(): State<RoomId?> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private fun
here and below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, done in the latest commit: e46503a
private val factory: UserProfilePresenter.Factory, | ||
) : UserProfilePresenterFactory { | ||
override fun create(userId: UserId): Presenter<UserProfileState> = factory.create(userId) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see any, sorry... I was going to suggest trying to reuse UserProfilePresenter.Factory
but that's not possible since the AssistedFactory
needs to return a concrete type.
The best I could get was making UserProfilePresenter.Factory
implement UserProfilePresenterFactory
, then use it in DefaultUserProfilePresenterFactory
like this:
@ContributesBinding(SessionScope::class)
class DefaultUserProfilePresenterFactory @Inject constructor(
private val factory: UserProfilePresenter.Factory,
) : UserProfilePresenterFactory by factory
Quality Gate passedIssues Measures |
Content
Let
RoomMemberDetailsPresenter
delegates the computation of profile state toUserProfilePresenter
, which allow to reduce code duplication.Motivation and context
Less code duplication (production and test).
Preparatory work for #3684
Screenshots / GIFs
Tests
There should be no change.
Tested devices
Checklist